package com.na.report.db;

import java.util.Date;

public class NetTraffic implements Comparable<NetTraffic> {

	public int id;
	public String type; // 流量类型(流入/流出)
	public String opcode; // 协议号
	public String opname; // 协议名
	public int count; // 该协议被传输次数
	public long length; // 该协议数据总长度
	public Date time;
	public String ip;

	public NetTraffic() {
	}

	public NetTraffic(String type, String opcode, String opname, int count, long length, String ip) {
		this.type = type;
		this.opcode = opcode;
		this.opname = opname;
		this.count = count;
		this.length = length;
		this.time = new Date();
		this.ip = ip;
	}

	@Override
	public String toString() {
		return "[id=" + id + ", type=" + type + ", opcode=" + opcode
				+ ", opname=" + opname + ", count=" + count + ", length=" + length
				+ ", time=" + time + ", ip=" + ip + "]";
	}

	@Override
	public int compareTo(NetTraffic o) {
		if (length < o.length)
			return 1;
		if (length > o.length)
			return -1;
		return 0;
	}

}
